Nx Object
The objects in the NXOpen namespace have a rich set of properties that let us get information about the objects and (in
some cases) modify them. The complete properties of each object are documented in the NX Open Reference Guide, so the
overview provided here is just to help you understand the basic concepts.
Nx Object Properties
Most objects in the NX Open object hierarchy inherit from NXOpen.NXObject, so its properties are very important because
they trickle down to all the lower-level objects. The properties can be divided into several categories, as outlined
below:
Type and Subtype Properties
Each NX Open object has a Type property and a Subtype property, which you will often use to make decisions about how to
process the object. Some objects such as solid geometry objects have an additional SolidBodyType property. These
properties are read-only, of course — you cannot change the type of an object.
Suppose the user has selected an object, for example. You might want to test whether this object is an ellipse before
processing it.
Example Code:
using NXOpen;
using NXOpen.UF;
namespace ObjectProperties
{
public class Class1
{
public static void Main(string[] args)
{
Session theSession = Session.GetSession();
Part WorkPart = theSession.Parts.Work;
UFSession ufs = UFSession.GetUFSession();
int type;
int subType;
foreach(Curve crv in WorkPart.Curves)
{
ufs.Obj.AskTypeAndSubtype(crv.Tag, out type, out subType);
if(type==UFConstants.UF_cone_type && subType==UFConstants.UF_conic_ellipse_subtype)
{
// Do something
crv.Color = 127;
crv.RedisplayObject();
}
}
}
public static int GetUnloadOption(string args)
{
return (int)NXOpen.Session.LibraryUnloadOption.Immediately;
}
}
}